// https://iai.sh.cn/problem/583
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  int x = 0, y = 0;
  int dir = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'L') {
      dir = (dir + 1) % 4;
    } else if (s[i] == 'R') {
      dir = (dir + 3) % 4;
    } else if (s[i] == 'F') {
      switch (dir) {
      case 0:
        x++;
        break;
      case 1:
        y++;
        break;
      case 2:
        x--;
        break;
      case 3:
        y--;
        break;
      }
    } else if (s[i] == 'B') {
      switch (dir) {
      case 0:
        x--;
        break;
      case 1:
        y--;
        break;
      case 2:
        x++;
        break;
      case 3:
        y++;
        break;
      }
    }
  }
  cout << x << " " << y << endl;
  return 0;
}